
import misc.utils as utils
from render.lua_render_help import LuaConvert

# Compare this snippet from converter/multi_convert.py:
def const_render(sheet_name, data):
    lua_code = f"g_config.{sheet_name} = {{ {utils.line}"
    for key, value in data.items():
        t_value = value["value"]
        t_note = value.get("note", "")
        c = LuaConvert(utils.tab, utils.line)
        t_value = c._convert_value(t_value, 2)
        lua_code += f"{utils.tab}{key} = {t_value}, -- {t_note} {utils.line}"
    lua_code += "}" + utils.line
    return lua_code

def single_render(sheet_name, data):
    lua_code = f"g_config.{sheet_name} ="
    convert = LuaConvert(utils.tab, utils.line)
    lua_code += convert.convert(data)
    lua_code += utils.line
    return lua_code

def multi_render(sheet_name,data):
    lua_code = f"g_config.{sheet_name} = {{}} {utils.line}"
    for key, value in data.items():
        lua_code += f"g_config.{sheet_name}.{key} = {utils.line}"
        convert = LuaConvert(utils.tab, utils.line)
        lua_code += convert.convert(value)
        lua_code += utils.line
    return lua_code
